import { _decorator, Component, log, Node, v3, Vec3 } from 'cc';
import { GameCache, GlobalContext } from '../../DataCenter/GlobalContext';
import GameInfo from '../../DataCenter/GameInfo';
const { ccclass, property } = _decorator;

@ccclass('RoleBase')
export class RoleBase extends Component {
    attack: number = 0;
    attackSpeed: number = 0;

    index: number = -1;

    set pos(vec: Vec3) {
        this.node.setPosition(vec);
        vec = v3(vec.x + GlobalContext.MapSize.x / 2, Math.abs(vec.y - GlobalContext.MapSize.y / 2), 0);
        vec = v3(Math.floor(vec.x / GlobalContext.TileSize), Math.floor(vec.y / GlobalContext.TileSize), 0)
        let index = vec.x + vec.y * 6;
        GameInfo.inst.updateChace(this, index, GameCache.ready);
        this.index = index;
    }
}


